package catp02;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main2 {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x=Integer.parseInt(sc.nextLine());
		//StringBuilder id = new StringBuilder();
		String choice = sc.nextLine();
		
		switch(choice){
		case "sort1":
			
			int[] year = null;
			int[] month = null;
			int[] day = null;
			
			for(int i=0;i<x;i++){
				String id = sc.nextLine();

				year[i]=id.substring(6, 10);
				month[i]=id.substring(10, 12);
				day[i]=id.substring(12, 14);
			}
			return year+"-"+month+"-"+day;
			break;
		case "sort2":
			
			break;
		}
	}
	
	
}

